from util.constant import Constant
import requests


def request_address(address):
    data = {
        'keyword': address,
        'offset': 0,
        'limit': 20
    }
    address_request = requests.get(Constant.ADDRESS_REQUEST_URL, params=data, headers=Constant.headers)
    response = address_request.json()
    address_list = []
    for res in response:
        address_list.append({
            'address': res['address'],
            'latitude': res['latitude'],
            'longitude': res['longitude']
        })
    return address_list
